package thread;

import com.google.common.util.concurrent.ThreadFactoryBuilder;

import java.util.concurrent.*;

/**
 * 线程池
 *
 * @author wei.yang on 2018/8/7
 */
public class Worker {

    private static final Object object=new Object();
    private static final int POOL_SIZE = 10;

    private static final int CORE_SIZE = 10;

    private static ThreadFactory namedThreadFactory = new ThreadFactoryBuilder().setNameFormat("THREAD-%d").build();

    private static ExecutorService worker =
            new ThreadPoolExecutor(CORE_SIZE, POOL_SIZE, 0, TimeUnit.SECONDS, new LinkedBlockingDeque<>(),
                    namedThreadFactory);

    public static ExecutorService getWorker() {
        return worker;
    }
}
